//cineplex.h

#ifndef CINEPLEX_H
#define CINEPLEX_H

#include "list.h"
#include "customer.h"
#include "thread.h"
#include "system.h"

class Ticket
{
public:
	int num;

	Ticket();
};

class Popcorn
{
public:
	Popcorn();
};

class Soda
{
public:
	Soda();
};

#include "manager.h"
#include "lobby.h"
#include "ticketclerk.h"
#include "foodclerk.h"
#include "tickettaker.h"
#include "movietech.h"

//define important variables here
//the number of customers should be a macro to allow us to malloc the ticket pool
#define MAX_CUSTOMERS 25
#define MAX_TIX_CLERKS 3
#define MAX_FOOD_CLERKS 3
#define MAX_TIX_TAKERS 3
#define NUM_ROWS 5
#define NUM_COLS 5

extern int NUM_CUSTOMERS;
extern int NUM_TIX_CLERKS;
extern int NUM_FOOD_CLERKS;
extern int NUM_TIX_TAKERS;
//extern int NUM_ROWS;
//extern int NUM_COLS;

class Theater
{
public:
	Customer** seating;
	Lock* seatingLock;
	int seatsFilled;
	int totalSeats;
	bool movieStarted;
	
	Theater();
	~Theater();
};

class Bathroom
{
public:
	Bathroom();
	
	Lock* brLock;
};

class Cineplex
{
public:
	IterList* customers;
	IterList* tixLines;
	IterList* tixClerks;
	IterList* foodLines;
	IterList* foodClerks;
	IterList* entryLines;
	IterList* ticketTakers;
	
	Lock* tixLinesLock;
	Lock* foodLinesLock;
	Lock* entryLinesLock;
	
	Condition* waitNotEmpty;
	
	Theater* theater;
	Manager* manager;
	Lobby* lobby;
	Ticket* ticketPool;
	Popcorn* popcornPool;
	Soda* sodaPool;
	MovieTech* tech;
	Bathroom* bathroom;
	
	int tixPassedOut;
	int popcornSold;
	int sodaSold;
	int customersRunning;
	int letPeopleIn;
	int runSchedulers;
	
	int testPattern;
	int testAgentsLeft;
	
	Cineplex(int run, int _c, int _tc, int _fc, int _tt, int pat);
	Cineplex();
	~Cineplex();
	void Start();
};

static Cineplex* p_cineplex;
static int singleExists;

static void startCustomer(int ptr);
static void startTC(int ptr);
static void startFC(int ptr);
static void startTT(int ptr);
static void startManager(int ptr);
static void startTech(int ptr);
static void startLobby(int ptr);

Cineplex* getCineplex();
Cineplex* getCineplex(int run, int _c, int _tc, int _fc, int _tt, int pat);
void destroyCineplex();


int getRandPercent();



#endif
